using UnityEngine;
using System.Collections;

public class SettingsView : MonoBehaviour
{
	public Settings settingsManager;
	public MusicManager musicManager;
	public UIButtonMessage btnFullscreen;
	public UIButtonMessage btnWindowed;
	public UIButtonMessage btnSkipUnread;
	public UISlider AutoPrintSpeed;
	public UISlider TextPrintSpeed;
	public UISlider BGMVolume;
	public UISlider SoundVolume;
	public UISlider VoiceVolume;

		// Use this for initialization
		void Awake ()
		{
			settingsManager = GameObject.Find("MenuManager").GetComponent<Settings>();
			musicManager = GameObject.Find("MenuManager").GetComponent<MusicManager>();

			btnFullscreen = GameObject.Find("WindowedBtn").GetComponent<UIButtonMessage>();
			btnWindowed = GameObject.Find("FullScreenBtn").GetComponent<UIButtonMessage>();
			btnSkipUnread = GameObject.Find("SkipUnreadBtn").GetComponent<UIButtonMessage>();
			AutoPrintSpeed = GameObject.Find("AutoAdvanceSpeed").GetComponent<UISlider>();
			TextPrintSpeed = GameObject.Find("TextDisplaySpeed").GetComponent<UISlider>();
			BGMVolume = GameObject.Find("MusicVolume").GetComponent<UISlider>();
			SoundVolume = GameObject.Find("SoundVolume").GetComponent<UISlider>();
			VoiceVolume = GameObject.Find("VoiceVolume").GetComponent<UISlider>();
		}

		void Start()
		{
			BGMVolume.sliderValue = 0.75f;
		}

		// Update is called once per frame
		void Update ()
		{
		if(Application.loadedLevelName == "PuzzleRoom")
		{
			settingsManager = GameObject.Find("MenuManager").GetComponent<Settings>();
			//dmManager.dm.setDialogueID(DialoguerDialogues.First_Puzzle_Items);
		}
		}

	public void onFullscreen()
	{
		settingsManager.ChangeViewToFullscreen();
	}

	public void onWindowed()
	{
		settingsManager.ChangeViewToWindowed();
	}

	public void onAutoSpeedChange()
	{
		settingsManager.AutoPrintAdjustSpeed(AutoPrintSpeed.sliderValue);
	}

	public void onTextSpeedChange()
	{
		settingsManager.TextPrintAdjustSpeed(TextPrintSpeed.sliderValue);
	}

	public void onBGMVolumeChange()
	{
		musicManager.BGMAdjustVolume(BGMVolume.sliderValue);
	}

	public void onSoundVolumeChange()
	{
		musicManager.SoundAdjustVolume(SoundVolume.sliderValue);
	}

	public void onVoiceVolumeChange()
	{
		musicManager.VoiceAdjustVolume(VoiceVolume.sliderValue);
	}
}

